//
//  sensor.h
//  Embedded_System
//
//  Created by Edward Bassan on 2/26/14.
//  Copyright (c) 2014 Edward Bassan. All rights reserved.
//


//---- Pins --------//

#define PING_PIN  7
#define WAIT_FOR_ECHO_MS 5000

//--------------------//

#ifndef Embedded_System_sensor_h
#define Embedded_System_sensor_h

typedef struct sensor {
    //sensor fields
    long duration;
    long distanceFromObject;

    //member functions
    int(*setDuration)(struct sensor *, long);
    long(*getDuration)(struct sensor *);
    long(*microsecondsToInches)(struct sensor *, long);
    int(*display)(struct sensor *);
    int(*ping)(struct sensor *, int);
    int(*setDistanceFromObject)(struct sensor *, long);
    long(*getDistanceFromObject)(struct sensor *);
    int(*pulseIn)(struct sensor *, int, int, int);
    
}sensorStr;

typedef sensorStr * SensorPtr;

//sensor functions
SensorPtr newSensorConstructor(void);
long microsecondsToInches(SensorPtr this, long duration);
int setDuration(SensorPtr this, long duration);
long getDuration(SensorPtr this);
int display(SensorPtr this);
int ping(SensorPtr this, int pin);
long getDistanceFromObject(SensorPtr this);
int setDistanceFromObject(SensorPtr this, long distance);
int pulseIn(SensorPtr this, int pin, int level, int timeout);

#endif
